﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Read.API.Application.Command.RoleCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        private readonly IMediator mediator;

        public RoleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 角色列表显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIPaging<Role>> GetRole([FromQuery]GetRoleCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 回显角色数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Role>>> FanRole([FromQuery]FanRoleCommand request)
        {
            return mediator.Send(request);
        }
    }
}
